package stu.sup.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import stu.sup.entity.ProductTpicInfo;
import stu.sup.entity.ProductTpicInfoExample;
import stu.sup.mapper.ProductTpicInfoMapper;
import stu.sup.service.IPicInfoService;

import java.util.List;

/**
 * Created by HUAWEI on 2020/6/26.
 */
@Service
@Transactional
public class PrcInfoServiceImpl implements IPicInfoService {
    @Autowired
    private ProductTpicInfoMapper productTpicInfoMapper;
    @Override
    public boolean addInfo(ProductTpicInfo productTpicInfo) {
        int count=productTpicInfoMapper.insert(productTpicInfo);
        return count==0?false:true;
    }

    @Override
    public ProductTpicInfo selectById(int InfoId) {
        return productTpicInfoMapper.selectByPrimaryKey(InfoId);
    }

    @Override
    public boolean delate(int infoId) {
        int count=productTpicInfoMapper.deleteByPrimaryKey(infoId);
        return count==0?false:true;
    }

    @Override
    public int update(ProductTpicInfo productTpicInfo) {
        return productTpicInfoMapper.updateByPrimaryKey(productTpicInfo);
    }

    @Override
    public List<ProductTpicInfo> selectbypId(int id) {
        ProductTpicInfoExample example=new ProductTpicInfoExample();
       ProductTpicInfoExample.Criteria criteria=example.createCriteria();
        criteria.andProductIdEqualTo(id);
        return productTpicInfoMapper.selectByExample(example);
    }
}
